home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / quad / RCS / Quad_AddUns.c,v < prev    next >
Encoding:
Text File  |  1991-03-18  |  1.8 KB  |  83 lines

  1. head     1.1;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.1
  10. date     91.03.18.12.18.49;  author kupfer;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @Add two unsigned quads.
  17. @
  18.  
  19.  
  20.  
  21. 1.1
  22. log
  23. @Initial revision
  24. @
  25. text
  26. @/* 
  27.  * Quad_AddUns.c --
  28.  *
  29.  *    Quad_AddUns libc routine.
  30.  *
  31.  * Copyright 1991 Regents of the University of California
  32.  * Permission to use, copy, modify, and distribute this
  33.  * software and its documentation for any purpose and without
  34.  * fee is hereby granted, provided that this copyright
  35.  * notice appears in all copies.  The University of California
  36.  * makes no representations about the suitability of this
  37.  * software for any purpose.  It is provided "as is" without
  38.  * express or implied warranty.
  39.  */
  40.  
  41. #ifndef lint
  42. static char rcsid[] = "$Header: /sprite/lib/forms/RCS/proto.c,v 1.5 91/02/09 13:24:44 ouster Exp $ SPRITE (Berkeley)";
  43. #endif /* not lint */
  44.  
  45. #include <quad.h>
  46.  
  47.  
  48. /*
  49.  *----------------------------------------------------------------------
  50.  *
  51.  * Quad_AddUns --
  52.  *
  53.  *    Add an unsigned quad to another unsigned quad.  The temporary 
  54.  *    variable is needed so that a u_quad can be added to itself.
  55.  *
  56.  * Results:
  57.  *    The sum of the 2 arguments.
  58.  *
  59.  * Side effects:
  60.  *    None.
  61.  *
  62.  *----------------------------------------------------------------------
  63.  */
  64.     
  65. void
  66. Quad_AddUns(uQuad1, uQuad2, resultPtr)
  67.     u_quad uQuad1;        /* in */
  68.     u_quad uQuad2;        /* in */
  69.     u_quad *resultPtr;        /* out */
  70. {
  71.     unsigned long newLeastSig;    /* new least significant word */
  72.  
  73.     newLeastSig = uQuad1.val[QUAD_LEAST_SIG] + uQuad2.val[QUAD_LEAST_SIG]; 
  74.     resultPtr->val[QUAD_MOST_SIG] = uQuad1.val[QUAD_MOST_SIG]
  75.         + uQuad2.val[QUAD_MOST_SIG];
  76.     if (newLeastSig < uQuad1.val[QUAD_LEAST_SIG]
  77.         && newLeastSig < uQuad2.val[QUAD_LEAST_SIG]) {
  78.     resultPtr->val[QUAD_MOST_SIG]++; 
  79.     }
  80.     resultPtr->val[QUAD_LEAST_SIG] = newLeastSig; 
  81. }
  82. @
  83.